<template>
  <page-body>
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center purchasestoragecabinets_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub purchasestoragecabinets_fd0_0'>
          <view class='flex flex-wrap align-center purchasestoragecabinets_fd0_0_c0' @tap.stop="handleJumpDiy"
            data-type="back" data-url="1">
            <text class='fu-iconfont2  purchasestoragecabinets_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='purchasestoragecabinets_fd0_0_c1_c0'>购买储物柜</text>
          </view>
          <view class='flex flex-wrap align-center justify-end purchasestoragecabinets_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <!-- <view
        class="flex flex-direction flex-wrap align-stretch justify-center benben-flex-layout purchasestoragecabinets_flex_1">
        <view class='flex flex-direction align-center self-center justify-center purchasestoragecabinets_fd1_0'>
          <text>储物柜</text>
          <view class='flex flex-wrap align-center purchasestoragecabinets_fd1_0_c1'>
          </view>
          <view class='flex flex-wrap align-center purchasestoragecabinets_fd1_0_c1'>
          </view>
          <view class='flex flex-wrap align-center purchasestoragecabinets_fd1_0_c1'>
          </view>
        </view>
      </view> -->
      <view
        class="flex flex-direction flex-wrap align-stretch justify-center benben-flex-layout purchasestoragecabinets_flex_1">
        <view class='flex flex-direction align-center self-center justify-center purchasestoragecabinets_fd1_0'>

          <view class='flex flex-wrap align-center purchasestoragecabinets_fd1_0_c1'>
          </view>
          <view class='flex flex-wrap align-center purchasestoragecabinets_fd1_0_c1'>
          </view>
          <view class='flex flex-wrap align-center purchasestoragecabinets_fd1_0_c1'>
          </view>
        </view>
      </view>
      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction align-stretch benben-flex-layout">
        <view class='flex flex-wrap align-center justify-between purchasestoragecabinets_fd2_0'>
          <text>储物柜数量</text>
          <view class='flex flex-wrap align-center'>
            <benben-input class='purchasestoragecabinets_fd2_0_c1_c0' type="number" :placeholder="`请输入需要购买的储物柜数量`"
              confirm-type="done" :maxlength="2" :adjust-position='true' v-model="number"
              placeholder-style="color:#999;font-size:28rpx" />
            <text class='purchasestoragecabinets_fd2_0_c1_c1'>个</text>
          </view>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout purchasestoragecabinets_flex_3">
        <text class='purchasestoragecabinets_fd3_0'>选择支付方式</text>
        <benben-select-diy ref="showSelectPopup1721117799632"
          class-name='flex flex-direction flex-wrap align-stretch flex' :items.sync="zhifufangshi" v-model="zhifu"
          default-type="value" default-label="name" :allow-cancel='false' type="radio" :disabled='false'>
          <template v-for='(item,key0) in zhifufangshi'>
            <view v-if="item.isSelected" class='flex align-center flex purchasestoragecabinets_fd3_1_c0' :key="key0"
              @tap="$refs.showSelectPopup1721117799632.tapHandle(key0)">
              <image class='purchasestoragecabinets_fd3_1_c0_c0' mode="aspectFit" :src='item.image'></image>
              <text class='purchasestoragecabinets_fd3_1_c0_c1'>{{item.name}}</text>
              <image class='purchasestoragecabinets_fd3_1_c0_c2' mode="aspectFit" :src='STATIC_URL+"15.png"'></image>
            </view>
            <view v-else class='flex align-center flex purchasestoragecabinets_fd3_1_c0' :key="key0"
              @tap="$refs.showSelectPopup1721117799632.tapHandle(key0)">
              <image class='purchasestoragecabinets_fd3_1_c0_c0' mode="aspectFit" :src='item.image'></image>
              <text class='purchasestoragecabinets_fd3_1_c0_c1'>{{item.name}}</text>
              <image class='purchasestoragecabinets_fd3_1_c1_c2' mode="aspectFit" :src='STATIC_URL+"82.png"'></image>
            </view>
          </template></benben-select-diy>
      </view>

      <!---flex布局flex布局结束-->
      <view
        class="flex flex-wrap align-center justify-center benben-position-layout flex purchasestoragecabinets_flex_4"
        :style="{height:(120+bottomSafeAreaRpx)+'rpx',paddingBottom:bottomSafeAreaRpx+'rpx', }">
        <button class='purchasestoragecabinets_fd4_0' @tap.stop="submit" data-type="navigateTo"
          :data-url="`/pages/homePage/paysuccess/paysuccess`">立即购买</button>

      </view>
      <view :style="{height: (120+bottomSafeAreaRpx)+'rpx'}"></view>


    </view>
  </page-body>
</template>
<script>
  export default {
    components: {},


    data() {
      return {
        "zhifufangshi": [
          //   {
          //   "name": "微信支付",
          //   "value": "2",
          //   "image": require('@/static/images/190.png')
          // },
          {
            "name": "支付宝支付",
            "value": "3",
            "image": require('@/static/images/197.png')
          }
        ],
        "zhifu": "3",
        number: ''
      };
    },
    computed: {

    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      async goPay(info) {
        this.$api.post(global.apiUrls.post645cc048d1f34, {
          order_sn: info.ordernumber
        }).then(res => {
          // console.log('res.data.data:', decodeURIComponent(res.data.data))
          if (res.data.code == 1) {
            uni.requestPayment({
              provider: 'alipay',
              orderInfo: res.data.data,
              success: e => {
                if (e.errMsg == 'requestPayment:ok') {
                  uni.redirectTo({
                    url: `/pages/homePage/paysuccess/paysuccess?info=${info.ordernumber}`
                  })
                }
              },
              fail: e => {
                console.log('eeee', e)
                if (e.errMsg == 'requestPayment:fail canceled') {
                  this.$message.info(this.$t('取消支付'));
                } else {
                  this.$message.info(this.$t('支付失败,请稍后重试'));
                }
              },
              complete: () => {
                this.loading = false;
              }
            });

          }
        })
      },
      submit() {
        if (!parseFloat(this.number)) {
          this.$message.info('请输入数量')
          return;
        }
        if (parseFloat(this.number) > 10) {
          this.$message.info('请输入有效数量，最多可购买10个')
          return;
        }
        this.$api.post(global.apiUrls.post6698e8ea73ebf, {
          number: this.number
        }).then(res => {
          if (res.data.code == 1) {
            this.goPay(res.data.data)
          }
        })
      },
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .purchasestoragecabinets_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .purchasestoragecabinets_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .purchasestoragecabinets_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .purchasestoragecabinets_fd0_0_c0 {
    width: 120rpx;
  }

  .purchasestoragecabinets_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .purchasestoragecabinets_flex_1 {
    background: url(image-path('214.png')) no-repeat;
    background-size: 100% 100%;
    width: 217rpx;
    padding: 16rpx 0;
    margin: 50rpx auto 24rpx auto;
  }

  .purchasestoragecabinets_fd1_0_c1 {
    background: url(image-path('216.png')) no-repeat;
    background-size: 100% 100%;
    width: 60rpx;
    height: 60rpx;
    margin: 16rpx 0rpx 0rpx 0rpx;
  }

  .purchasestoragecabinets_fd1_0 {
    // background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
    padding: 50rpx 0;
  }

  .purchasestoragecabinets_fd2_0_c1_c1 {
    margin: 0rpx 0rpx 0rpx 16rpx;
  }

  .purchasestoragecabinets_fd2_0_c1_c0 {
    background: #F2F3F5;
    border-radius: 12rpx 12rpx 12rpx 12rpx;
    height: 64rpx;
    line-height: 64rpx;
    width: 470rpx;
    padding: 0 24rpx;
  }

  .purchasestoragecabinets_fd2_0 {
    line-height: 100rpx;
    height: 100rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
  }

  .purchasestoragecabinets_flex_3 {
    margin: 0rpx 24rpx 120rpx 24rpx;
  }

  .purchasestoragecabinets_fd3_1_c1_c2 {
    width: 37rpx;
    height: 37rpx;
    border-radius: 18rpx 18rpx 18rpx 18rpx;
    margin: 0rpx 0rpx 0rpx auto;
  }

  .purchasestoragecabinets_fd3_1_c0_c2 {
    width: 36rpx;
    height: 36rpx;
    border-radius: 18rpx 18rpx 18rpx 18rpx;
    margin: 0rpx 0rpx 0rpx auto;
  }

  .purchasestoragecabinets_fd3_1_c0_c1 {
    font-size: 32rpx;
    font-weight: 400;
    color: #333333;
    line-height: 45rpx;
  }

  .purchasestoragecabinets_fd3_1_c0_c0 {
    width: 56rpx;
    height: 56rpx;
    border-radius: 26rpx 26rpx 26rpx 26rpx;
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .purchasestoragecabinets_fd3_1_c0 {
    padding: 32rpx 0rpx 32rpx 0rpx;
  }

  .purchasestoragecabinets_fd3_0 {
    font-size: 30rpx;
    font-weight: 800;
    color: var(--benbenFontColor0);
    padding: 32rpx 0rpx 32rpx 0rpx;
    line-height: 40rpx;
  }

  .purchasestoragecabinets_flex_4 {
    background: var(--benbenbgColor1);
    width: 750rpx;
    height: 120rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
    left: 0rpx;
    background-size: 100% auto;
  }

  .purchasestoragecabinets_fd4_0 {
    background: linear-gradient(180deg, #176BE8 0%, #5A5CFC 100%);
    border-radius: 44rpx 44rpx 44rpx 44rpx;
    width: 686rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
    height: 88rpx;
  }
</style>
